package com.hrms.controller;


import com.hrms.pojo.AttenManage;
import com.hrms.service.AttenManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LK
 * @since 2021-10-19
 */
@RestController
@RequestMapping("/attenManage")
public class AttenManageController {

	@Autowired
	AttenManageService attenManageService;

	@RequestMapping("/List")
	public HashMap<String, Object> list(AttenManage a) {
		return attenManageService.select(a);
	}
	//修改
	@RequestMapping("/update")
	public HashMap<String,Object>  update(AttenManage a){
		return attenManageService.update(a);
	}
	//新增
	@RequestMapping("/add")
	public HashMap<String,Object> add( AttenManage a){
		if ("迟到".equals(a.getAttenType())) {
			a.setAttenReward("-20");
		} else if ("旷工".equals(a.getAttenType())) {
			a.setAttenReward("-50");
		}else if ("请假".equals(a.getAttenType())) {
			a.setAttenReward("-10");
		}else if ("加班".equals(a.getAttenType())) {
			a.setAttenReward("+50");
		}else if ("出差".equals(a.getAttenType())) {
			a.setAttenReward("+100");
		}else if ("调班".equals(a.getAttenType())) {
			a.setAttenReward("0");
		}else if ("停工".equals(a.getAttenType())) {
			a.setAttenReward("-1");
		}
		return attenManageService.add(a);
	}

	//删除
	@RequestMapping("/del")
	public HashMap<String,Object> del(Integer id){
		return attenManageService.del(id);
	}

}

